package com.example.template.core.utils;

/**
 * @Description TODO
 * @Author meko
 **/
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;

/**
 * Created by rale on 5/29/17.
 * 将图片存储至本地
 */
public class FileUtil {

    public static void save(byte[] bytes, String fileName, String path) throws IOException {
        createDirectory(path);
        FileOutputStream os = new FileOutputStream(path + fileName);
        os.write(bytes);
        os.close();
    }

    private static boolean isExistPath(String path) {
        File file = new File(path);
        if (file.exists()) {//判断文件目录的存在
            return true;
        }else{
            return false;
        }
    }
    private static void createDirectory(String path){
        if(!isExistPath(path)){
            File file=new File(path);
            file.mkdirs();
        }
    }
}
